/**
Filename : SysuserDao.java
Date     : 2015年11月10日
Author   : qp.wu@suirui.com
Company  : Suirui Co.,Ltd.
*/
package org.wuqiupeng.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import org.wuqiupeng.entity.UserRecord;

@Repository
public class SysuserDao {
	private static final Logger log=LoggerFactory.getLogger(SysuserDao.class);
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	
	public List<UserRecord> getAllUser()
	{
		String sql="select * from sysuser";
		System.out.println(sql);
		return jdbcTemplate.query(sql, new UserEntityMapper());
	}
	
	private static final class UserEntityMapper implements RowMapper<UserRecord>{   
        public UserRecord mapRow(ResultSet rs, int rowNum) throws SQLException {  
        	System.out.println("rowNum = " + rowNum);
        	UserRecord record = new UserRecord();  
        	record.setId(rs.getString("id"));
        	record.setUsernmae(rs.getString("username"));
            return record;   
        }   
    }
}

